From 77e72735cf9f05592ef055cc8348813ce9e59cd0 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 17 Dec 2015 21:50:11 +0300 Subject: [PATCH] add more fields to SerializedDependency --- src/cargo/core/dependency.rs | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/src/cargo/core/dependency.rs b/src/cargo/core/dependency.rs index 1788a1fb7..ce538d964 100644 --- a/src/cargo/core/dependency.rs +++ b/src/cargo/core/dependency.rs @@ -33,16 +33,29 @@ pub struct Dependency { #[derive(RustcEncodable)] -struct SerializedDependency { - name: String, - req: String +struct SerializedDependency<'a> { + name: &'a str, + source: &'a SourceId, + req: String, + kind: Kind, + + optional: bool, + uses_default_features: bool, + features: &'a [String], + target: &'a Option<&'a str>, } impl Encodable for Dependency { fn encode(&self, s: &mut S) -> Result<(), S::Error> { SerializedDependency { - name: self.name().to_string(), - req: self.version_req().to_string() + name: self.name(), + source: &self.source_id(), + req: self.version_req().to_string(), + kind: self.kind(), + optional: self.is_optional(), + uses_default_features: self.uses_default_features(), + features: self.features(), + target: &self.only_for_platform(), }.encode(s) } } @@ -54,6 +67,16 @@ pub enum Kind { Build, } +impl Encodable for Kind { + fn encode(&self, s: &mut S) -> Result<(), S::Error> { + match *self { + Kind::Normal => None, + Kind::Development => Some("dev"), + Kind::Build => Some("build"), + }.encode(s) + } +} + impl DependencyInner { /// Attempt to create a `Dependency` from an entry in the manifest. pub fn parse(name: &str, @@ -235,4 +258,3 @@ impl Dependency { self.inner.matches_id(id) } } - -- 2.30.2